package co.yixiang.yshop.module.product.dal.mysql.storeproductstocklog;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.product.controller.admin.storeproductstockwarning.vo.StoreProductStockWarningRespVO;
import co.yixiang.yshop.module.product.dal.dataobject.storeproduct.StoreProductDO;
import co.yixiang.yshop.module.product.dal.dataobject.storeproductstocklog.StoreProductStockLogDO;
import co.yixiang.yshop.module.product.dal.dataobject.storeproductstockwarning.StoreProductStockWarningDO;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.product.controller.admin.storeproductstocklog.vo.*;

/**
 * 商品库存记录 Mapper
 *
 * @author admin
 */
@Mapper
public interface StoreProductStockLogMapper extends BaseMapperX<StoreProductStockLogDO> {

    default PageResult<StoreProductStockLogRespVO> selectPage(StoreProductStockLogPageReqVO reqVO) {
        return selectJoinPage(reqVO,StoreProductStockLogRespVO.class, new MPJLambdaWrapper<StoreProductStockLogDO>()
                .selectAll(StoreProductStockLogDO.class)
                .selectAs(StoreProductDO::getStoreName,StoreProductStockLogRespVO::getProductName)
                .selectAs(StoreProductDO::getImage,StoreProductStockLogRespVO::getProductImage)
                .selectAs(StoreProductDO::getImage,StoreProductStockLogRespVO::getProductImage)
                .leftJoin(StoreProductDO.class,StoreProductDO::getId,StoreProductStockLogDO::getGoodsId)
                .orderByDesc(StoreProductStockLogDO::getCreateTime)
        );
    }

    default List<StoreProductStockLogDO> selectList(StoreProductStockLogExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<StoreProductStockLogDO>()
                .eqIfPresent(StoreProductStockLogDO::getGoodsId, reqVO.getGoodsId())
                .eqIfPresent(StoreProductStockLogDO::getGoodsSkuText, reqVO.getGoodsSkuText())
                .eqIfPresent(StoreProductStockLogDO::getStock, reqVO.getStock())
                .eqIfPresent(StoreProductStockLogDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(StoreProductStockLogDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(StoreProductStockLogDO::getId));
    }

}
